﻿using JustTest.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace JustTest.Author
{
    public class GenericRepository<T> where T : class
    {
        protected DbContext context;

        public GenericRepository()
        {
            this.context = new JustTestDb() as DbContext;
        }

        public IEnumerable<T> All()
        {
            return this.context.Set<T>();
        }

        public T GetById(int Id)
        {
            return this.context.Set<T>().Find();
        }

        public virtual T Create(T item)
        {
            return this.context.Set<T>().Add(item);
        }

    }
}